package com.sale.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sale.common.core.constant.CacheNames;
import com.sale.common.core.domain.R;
import com.sale.common.core.exception.GlobalException;
import com.sale.common.dict.utils.DictUtils;
import com.sale.common.mybatis.core.page.PageQuery;
import com.sale.common.mybatis.core.page.TableDataInfo;
import com.sale.common.redis.utils.CacheUtils;
import com.sale.common.redis.utils.RedisUtils;
import com.sale.common.satoken.utils.LoginHelper;
import com.sale.system.api.RemoteCodeService;
import com.sale.system.api.RemoteReviewService;
import com.sale.system.api.RemoteStaffManagementService;
import com.sale.system.api.RemoteUserService;
import com.sale.system.api.domain.SysDictData;
import com.sale.system.api.domain.dto.SysCustomerBalance;
import com.sale.system.api.domain.dto.SysCustomerManagementResultDto;
import com.sale.system.api.domain.dto.SysStaffManagementDto;
import com.sale.system.api.domain.dto.SysTheDropApiDto;
import com.sale.system.api.domain.vo.SysAuditHistoryVo;
import com.sale.system.api.model.LoginUser;
import com.sale.system.domain.SysCustomerManagement;
import com.sale.system.domain.dto.CustomerManagementMqDto;
import com.sale.system.domain.dto.SysCustomerManagementDto;
import com.sale.system.domain.dto.SysOrderSupplierManagementMqDto;
import com.sale.system.domain.vo.SysCustomerManagementVo;
import com.sale.system.domain.vo.OrderReviewVo;
import com.sale.system.export.CustomerManagementExport;
import com.sale.system.export.CustomerManagementimportExport;
import com.sale.system.mapper.SysCustomerManagementMapper;
import com.sale.system.service.ISysExamineService;
import com.sale.system.service.SysCustomerManagementService;
import com.sale.system.util.SysVariousMqUtil;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 客户实现层
 *
 * @author jack
 */
@Service
@RequiredArgsConstructor
public class SysCustomerManagementServiceImpl implements SysCustomerManagementService {

    private final SysCustomerManagementMapper sysCustomerManagementMapper;

    @DubboReference
    private final RemoteCodeService remoteCodeService;

    @DubboReference
    private final RemoteReviewService remoteReviewService;

    @DubboReference
    RemoteUserService remoteUserService;

    @Resource
    ISysExamineService sysExamineService;


    /**
     * 客户列表
     *
     * @param sysCustomerManagementVo
     * @return
     */
    @Override
    public TableDataInfo<SysCustomerManagementDto> getList(SysCustomerManagementVo sysCustomerManagementVo, PageQuery pageQuery) {
        //状态
        List<SysDictData> statusArray = CacheUtils.get(CacheNames.SYS_DICT, "customer_status");
        Map<String, String> statusMap = statusArray.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));

        //客户等级
        List<SysDictData> levelArray = CacheUtils.get(CacheNames.SYS_DICT, "customer_level_type");
        Map<String, String> levelMap = levelArray.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));

        //用户列表
        List<SysTheDropApiDto> sysTheDropApiDtos = remoteUserService.userThe();
        Map<String, String> map = sysTheDropApiDtos.stream()
            .collect(Collectors.toMap(SysTheDropApiDto::getValue, SysTheDropApiDto::getLabel));


        Page<SysCustomerManagementDto> page = sysCustomerManagementMapper.getCoustomerList(pageQuery.build(), sysCustomerManagementVo);
        List<SysCustomerManagementDto> records = page.getRecords();
        for (SysCustomerManagementDto entity : records) {
            //销售人员
            if (entity.getAscriptionBy() != null) {
                String staffId = entity.getAscriptionBy();
                entity.setAscriptionByDict(map.get(staffId));
            }
            //状态
            entity.setAuditStatusDict(statusMap.get(entity.getAuditStatus()));
            //客户等级
            entity.setCustomerLevelDict(levelMap.get(entity.getCustomerLevel()));
        }
        return TableDataInfo.build(page);
    }

    /**
     * 客户新增
     *
     * @param sysCustomerManagementVo
     * @return
     */
    @Override
    public boolean addConverter(SysCustomerManagementVo sysCustomerManagementVo) throws Exception {
        //判断简称是否存在
        SysCustomerManagement sysCustomerManagementOne = sysCustomerManagementMapper.selectOne(new QueryWrapper<SysCustomerManagement>().lambda().eq(SysCustomerManagement::getCustomerAbbreviation, sysCustomerManagementVo.getCustomerAbbreviation()));
        if (sysCustomerManagementOne != null) {
            throw new GlobalException("该客户简称已经存在");
        }
        //获取当前登录人信息
        LoginUser loginUser = LoginHelper.getLoginUser();
        SysCustomerManagement sysCustomerManagement = new SysCustomerManagement();
        sysCustomerManagement.setDeptId(loginUser.getDeptId());
        sysCustomerManagement.setCustomerName(sysCustomerManagementVo.getCustomerName());
        sysCustomerManagement.setCustomerAbbreviation(sysCustomerManagementVo.getCustomerAbbreviation());
        String authorityCoding = remoteCodeService.authorityCoding("order:customer:list");
        if (authorityCoding == null) {
            throw new GlobalException("未进行单据配置,单据编码生成失败");
        }
        sysCustomerManagement.setCustomerNum(authorityCoding);
        sysCustomerManagement.setContactsInformation(sysCustomerManagementVo.getContactsInformation());
        sysCustomerManagement.setCustomerAddress(sysCustomerManagementVo.getCustomerAddress());
        sysCustomerManagement.setInvoicingInformation(sysCustomerManagementVo.getInvoicingInformation());
        sysCustomerManagement.setCustomerLevel(Integer.parseInt(sysCustomerManagementVo.getCustomerLevel()));
        sysCustomerManagement.setCreateBy(loginUser.getUsername());
        sysCustomerManagement.setContactsBy(sysCustomerManagementVo.getContactsBy());
        // sysCustomerManagement.setInvoicingInformation(sysCustomerManagementVo.getInvoicingInformation());
        sysCustomerManagement.setBusinessLicense(sysCustomerManagementVo.getBusinessLicense());
        sysCustomerManagement.setAuditStatus(1);
        sysCustomerManagement.setCreateTime(new Date());
        sysCustomerManagement.setCustomerCategoryCode(sysCustomerManagementVo.getCustomerCategoryCodeName());
        sysCustomerManagement.setRatepayerNumber(sysCustomerManagementVo.getRatepayerNumber());
        sysCustomerManagement.setContactsPhone(sysCustomerManagementVo.getContactsPhone());
        sysCustomerManagement.setConsigneeBy(sysCustomerManagementVo.getConsigneeBy());
        sysCustomerManagement.setConsigneePhone(sysCustomerManagementVo.getConsigneePhone());
        sysCustomerManagement.setConsigneeAddress(sysCustomerManagementVo.getConsigneeAddress());
        sysCustomerManagement.setBankDeposit(sysCustomerManagementVo.getBankDeposit());
        sysCustomerManagement.setOpenAccount(sysCustomerManagementVo.getOpenAccount());
        sysCustomerManagement.setRemark(sysCustomerManagementVo.getRemark());
        if (sysCustomerManagementVo.getAscriptionBy() != null) {
            sysCustomerManagement.setAscriptionBy(sysCustomerManagementVo.getAscriptionBy());
        }

        int insert = sysCustomerManagementMapper.insert(sysCustomerManagement);
        //mq发送消息
        CustomerManagementMqDto customerManagementMqDto = new CustomerManagementMqDto();
        BeanUtils.copyProperties(sysCustomerManagement, customerManagementMqDto);
        //租户id
        String userIdStr = LoginHelper.getUserIdStr();
        String tenantId = RedisUtils.getCacheObject(userIdStr);
        customerManagementMqDto.setTenantId(Long.parseLong(tenantId));
        customerManagementMqDto.setId(sysCustomerManagement.getId());
        SysVariousMqUtil.customerManagementMqSend(customerManagementMqDto);
        return insert > 0;
    }

    /**
     * 冻结客户
     *
     * @param id
     * @return
     */
    @Override
    public boolean frozenSupplier(Long id) {
        SysCustomerManagement sysCustomerManagement = sysCustomerManagementMapper.selectById(id);
        if (sysCustomerManagement.getAuditStatus() == 4) {
            sysCustomerManagement.setAuditStatus(5);
            return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
        } else {
            throw new GlobalException("只能冻结启用的客户");
        }

    }

    /**
     * 客户解冻
     *
     * @param id
     * @return
     */
    @Override
    public boolean thawSupplier(Long id) {
        SysCustomerManagement sysCustomerManagement = sysCustomerManagementMapper.selectById(id);
        if (sysCustomerManagement.getAuditStatus() == 5) {
            sysCustomerManagement.setAuditStatus(4);
            return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
        } else {
            throw new GlobalException("只能解冻已冻结的数据");
        }

    }

    /**
     * 撤销审核
     *
     * @param id
     * @return
     */
    @Override
    public boolean revokeApproval(Long id) {
        SysCustomerManagement sysCustomerManagement = sysCustomerManagementMapper.selectById(id);
        if (sysCustomerManagement.getAuditStatus() == 2) {
            sysCustomerManagement.setAuditStatus(1);
            return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
        } else {
            throw new GlobalException("只能撤销待审核的数据");
        }

    }

    /**
     * 客户信息导出
     *
     * @param sysCustomerManagementVo
     * @return
     */
    @Override
    public List<CustomerManagementExport> getInfoExport(SysCustomerManagementVo sysCustomerManagementVo) {
        List<CustomerManagementExport> exportList;
        //获取客户状态缓存字典数据
        List<SysDictData> array = DictUtils.getDictCache("customer_status");
        Map<String, String> actualMap = array.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));

        //获取客户等级缓存字典数据
        List<SysDictData> levelArray = DictUtils.getDictCache("customer_level");
        Map<String, String> levelMap = levelArray.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));

        if (sysCustomerManagementVo.getIdStr() == null) {
            exportList = sysCustomerManagementMapper.getExportList(sysCustomerManagementVo);
        } else {
            List<String> idList = Arrays.asList(sysCustomerManagementVo.getIdStr().split(","));
            exportList = sysCustomerManagementMapper.getDataByIdStr(idList);
        }
        for (CustomerManagementExport entity : exportList) {
            //状态
            entity.setAuditStatus(actualMap.get(entity.getAuditStatus()));
            //等级
            entity.setCustomerLevel(levelMap.get(entity.getCustomerLevel()));
            //归属人
            if (entity.getAscriptionBy() != null) {
                String ascriptionBy = entity.getAscriptionBy();
//                entity.setAscriptionBy(feignService.getUserName(Long.valueOf(ascriptionBy)));
            }
        }
        return exportList;
    }


    /**
     * 导入客户
     *
     * @param coCustomer
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String importMouldData(List<CustomerManagementimportExport> coCustomer) {
        if (coCustomer.size() == 0) {
            throw new GlobalException("导入客户信息不能为空！");
        }
        int successNum = 0;
        int failureNum = 0;
        StringBuilder successMsg = new StringBuilder();
        StringBuilder failureMsg = new StringBuilder();

        //获取客户等级缓存字典数据
        List<SysDictData> levelArray = DictUtils.getDictCache("customer_level");
        Map<String, String> levelMap = levelArray.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));

        for (CustomerManagementimportExport mouldModelExport : coCustomer) {
            SysCustomerManagement sysCustomerManagement = new SysCustomerManagement();
            try {
                //赋值
                sysCustomerManagement.setCustomerName(mouldModelExport.getCustomerName());
                //判断简称是否存在
                SysCustomerManagement sysCustomerManagementOne = sysCustomerManagementMapper.selectById(new QueryWrapper<SysCustomerManagement>().lambda().eq(SysCustomerManagement::getCustomerAbbreviation, mouldModelExport.getCustomerAbbreviation()));
                if (sysCustomerManagementOne != null) {
                    throw new GlobalException("该客户简称已经存在");
                }
                sysCustomerManagement.setCustomerAbbreviation(mouldModelExport.getCustomerAbbreviation());
                String authorityCoding = remoteCodeService.authorityCoding("order:customer:list");
                if (authorityCoding == null) {
                    throw new GlobalException("未进行单据配置,单据编码生成失败");
                }
                sysCustomerManagement.setCustomerNum(authorityCoding);
                //客户等级
                for (Map.Entry<String, String> entry : levelMap.entrySet()) {
                    if (entry.getValue().equals(mouldModelExport.getCustomerLevel())) {
                        sysCustomerManagement.setCustomerLevel(Integer.parseInt(entry.getKey()));
                        break;
                    }
                }
                //联系人
                sysCustomerManagement.setContactsBy(mouldModelExport.getContactsBy());
                sysCustomerManagement.setContactsInformation(mouldModelExport.getContactsInformation());
                //判断归属人是否存在
                String userName = mouldModelExport.getAscriptionBy();
//                if (userName != null) {
//                    AjaxResult byUserName = feignService.getByUserName(userName);
//                    SysUser data = JSON.parseObject(JSON.toJSONString(byUserName.get("data")), SysUser.class);
//                    if (data.getUserId() == null) {
//                        customerManagement.setAscriptionBy(0);
//                    } else {
//                        customerManagement.setAscriptionBy(data.getUserId());
//                    }
//                }
                //获取当前登录人信息
                LoginUser loginUser = LoginHelper.getLoginUser();
                sysCustomerManagement.setCreateBy(loginUser.getUsername());
                sysCustomerManagement.setAuditStatus(1);
                sysCustomerManagement.setCustomerAddress(mouldModelExport.getCustomerAddress());
                sysCustomerManagement.setCreateTime(new Date());
                sysCustomerManagement.setRemark(mouldModelExport.getRemark());
                sysCustomerManagement.setDeptId(loginUser.getDeptId());
                sysCustomerManagementMapper.insert(sysCustomerManagement);

                successNum++;
                successMsg.append(successNum).append("、客户信息 ").append(mouldModelExport.getCustomerName()).append(" 导入成功");

            } catch (Exception e) {
                failureNum++;
                String msg = failureNum + "、客户 " + mouldModelExport.getCustomerName() + " 导入失败：";
                failureMsg.append(msg).append(e.getMessage());
            }
        }
        if (failureNum > 0) {
            failureMsg.insert(0, "很抱歉，导入失败！共 " + failureNum + " 条数据格式不正确，错误如下：");
            throw new GlobalException(failureMsg.toString());
        } else {
            successMsg.insert(0, "恭喜您，数据已全部导入成功！共 " + successNum + " 条，数据如下：");
        }

        return successMsg.toString();
    }

    /**
     * 查看客户信息
     *
     * @param id
     * @return
     */
    @Override
    public SysCustomerManagementDto getCustomerById(Long id) {

        SysCustomerManagementDto customerManagementById = sysCustomerManagementMapper.getCustomerManagementById(id);
        //用户列表
        List<SysTheDropApiDto> sysTheDropApiDtos = remoteUserService.userThe();
        Map<String, String> map = sysTheDropApiDtos.stream()
            .collect(Collectors.toMap(SysTheDropApiDto::getValue, SysTheDropApiDto::getLabel));

        //销售人员
        if (customerManagementById.getAscriptionBy() != null) {
            String staffId = customerManagementById.getAscriptionBy();
            customerManagementById.setAscriptionByDict(map.get(staffId));
        }
        return customerManagementById;
    }

    /**
     * 删除客户
     *
     * @param ids
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean getDeleteByIds(String ids) throws Exception {
        List<SysCustomerManagement> sysCustomerManagementsList = new ArrayList<>();
        if (ids != null) {
            List<String> stringIds = Arrays.asList(ids.split(","));
            //获取客户列表
            List<SysCustomerManagement> sysCustomerManagements = sysCustomerManagementMapper.selectBatchIds(stringIds);

            for (SysCustomerManagement entity : sysCustomerManagements) {
                if (entity.getAuditStatus() != 1 && entity.getAuditStatus() != 6) {
                    throw new GlobalException("只能删除待提交、未通过的数据");
                }
                sysCustomerManagementsList.add(entity);
            }
        } else {
            throw new GlobalException("至少选择一条数据");
        }
        StringBuilder stringBuilder = new StringBuilder();
        for (SysCustomerManagement entity : sysCustomerManagementsList) {
            stringBuilder.append(entity.getId()).append(",");
        }
        StringBuilder stringBuilder1 = stringBuilder.deleteCharAt(stringBuilder.length() - 1);
        //mq同步删除客户
        CustomerManagementMqDto customerManagementMqDto = new CustomerManagementMqDto();
        customerManagementMqDto.setIdStr(stringBuilder1.toString());
        SysVariousMqUtil.customerManagementMqSendDelete(customerManagementMqDto);
        return sysCustomerManagementMapper.deleteBatchIds(sysCustomerManagementsList) > 0;
    }

    /**
     * 提交审核
     *
     * @param id
     * @return
     */
    @Override
    public boolean reivewSubmit(Long id) {
        SysCustomerManagement sysCustomerManagement = sysCustomerManagementMapper.selectById(id);
        if (sysCustomerManagement.getAuditStatus() == 1) {
            sysCustomerManagement.setAuditStatus(2);
            return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
        } else {
            throw new GlobalException("只能提交待审核的数据");
        }

    }


    /**
     * 修改客户
     *
     * @param sysCustomerManagementVo
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateCustomerById(SysCustomerManagementVo sysCustomerManagementVo) throws Exception {
        SysCustomerManagement sysCustomerManagement = sysCustomerManagementMapper.selectById(sysCustomerManagementVo.getId());
        BeanUtils.copyProperties(sysCustomerManagementVo, sysCustomerManagement);
        sysCustomerManagement.setContactsInformation(sysCustomerManagementVo.getInvoicingInformation());
        if (sysCustomerManagement.getAuditStatus() == 6) {
            //调用审核
            SysAuditHistoryVo sysAuditHistoryVo = new SysAuditHistoryVo();
            String perms = "informateManage:custom:examine";
            String auditDoc = sysCustomerManagement.getCustomerNum();
            sysAuditHistoryVo.setAuditDoc(auditDoc);
            sysAuditHistoryVo.setPerms(perms);
            int i = sysExamineService.updateHistoryAppConfigEdit(sysAuditHistoryVo);
            if (i > 0) {
                sysCustomerManagement.setAuditStatus(1);
                //mq发送消息
                CustomerManagementMqDto customerManagementMqDto = new CustomerManagementMqDto();
                BeanUtils.copyProperties(sysCustomerManagement, customerManagementMqDto);
                SysVariousMqUtil.customerManagementMqSend(customerManagementMqDto);
                //修改审核代办状态为已处理
//                    feignService.updateStatus(3, converterManagement.getConverterNum(), "加工商管理");
                return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
            } else {
                return false;
            }
        }
        //mq发送消息
        CustomerManagementMqDto customerManagementMqDto = new CustomerManagementMqDto();
        BeanUtils.copyProperties(sysCustomerManagement, customerManagementMqDto);
        SysVariousMqUtil.customerManagementMqSend(customerManagementMqDto);
        return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
    }

    /**
     * 客户审核
     *
     * @param orderReviewVo
     * @return
     */
    @Override
    public boolean customerReview(OrderReviewVo orderReviewVo) throws Exception {
        //获取当前登录人信息
        SysCustomerManagement sysCustomerManagement = sysCustomerManagementMapper.selectById(orderReviewVo.getId());
        if (sysCustomerManagement.getAuditStatus() == 2 || sysCustomerManagement.getAuditStatus() == 3) {
            String perms = "informateManage:custom:examine";
            int isAdopt = orderReviewVo.getIsAdopt();
            String auditDoc = sysCustomerManagement.getCustomerNum();
            String auditRemarks = orderReviewVo.getReviewComments();
            Long userId = LoginHelper.getUserId();
            SysAuditHistoryVo sysAuditHistoryVo = new SysAuditHistoryVo();
            sysAuditHistoryVo.setPerms(perms);
            sysAuditHistoryVo.setAuditType(2);
            sysAuditHistoryVo.setAuditState(isAdopt);
            sysAuditHistoryVo.setAuditRemarks(auditRemarks);
            sysAuditHistoryVo.setAuditDoc(auditDoc);
            sysAuditHistoryVo.setUserId(userId);
            int data = remoteReviewService.getSequence(sysAuditHistoryVo);
            if (data == 0) {
                throw new GlobalException("未对该审核进行配置");
            }
            //1:通过，2：审核中，3：没权限 4:该人已经审核过
            if (orderReviewVo.getIsAdopt() == 1) {
                if (data == 1) {
                    sysCustomerManagement.setAuditStatus(4);
                    return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
                } else if (data == 2) {
                    sysCustomerManagement.setAuditStatus(3);
                    return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
                } else if (data == 3) {
                    throw new GlobalException("没有审核权限");
                } else {
                    throw new GlobalException("该用户已经审核过");
                }
            } else {
                if (data == 1 || data == 2) {
                    sysCustomerManagement.setAuditStatus(6);
                    return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
                } else if (data == 3) {
                    throw new GlobalException("没有审核权限");
                } else {
                    throw new GlobalException("该用户已经审核过");
                }
            }
        } else {
            throw new GlobalException("只能对待审核和审核中的数据进行处理");
        }
    }

    /**
     * 通过客户名称获取客户id
     *
     * @param customerName
     * @return
     */
    @Override
    public SysCustomerManagement getCustomerId(String customerName) {
        return sysCustomerManagementMapper.getCustomerId(customerName);
    }

    /**
     * 修改客户启用状态
     *
     * @param sysCustomerManagementVo
     * @return
     */
    @Override
    public boolean updateStatus(SysCustomerManagementVo sysCustomerManagementVo) {
        SysCustomerManagement sysCustomerManagement = sysCustomerManagementMapper.selectById(sysCustomerManagementVo.getId());
        sysCustomerManagement.setAuditStatus(Integer.parseInt(sysCustomerManagementVo.getAuditStatus()));
        return sysCustomerManagementMapper.updateById(sysCustomerManagement) > 0;
    }

    /**
     * 获取启用状态客户列表
     *
     * @return
     */
    @Override
    public List<SysCustomerManagementDto> getOpenCustomer() {

        return sysCustomerManagementMapper.selectOpenCustomerList();
    }

    /**
     * 通过编码获取客户信息
     *
     * @param customerCode
     * @return
     */
    @Override
    public SysCustomerManagementResultDto getCustomerByCode(String customerCode) {
        SysCustomerManagementResultDto customerManagementResultDto = new SysCustomerManagementResultDto();
        SysCustomerManagement customerManagement = sysCustomerManagementMapper.selectOne(new QueryWrapper<SysCustomerManagement>()
            .lambda().eq(SysCustomerManagement::getCustomerNum, customerCode));
        BeanUtils.copyProperties(customerManagement, customerManagementResultDto);
        return customerManagementResultDto;
    }

    /**
     * 通过客户名称获取客户编码(财务模块使用)
     */
    @Override
    public String getCodeByCustomerName(String customerName) {
        return sysCustomerManagementMapper.getCodeByCustomerName(customerName);
    }

    /**
     * 通过客户编码更新余额
     */
    @Override
    public boolean updateClientBalance(SysCustomerBalance customerBalance) {
        return sysCustomerManagementMapper.updateClientBalance(customerBalance);
    }
}
